package com.smartrobot.smartrobot.util;

import android.content.Context;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by Administrator on 2015/1/7.
 */
public class Message implements Serializable,Cloneable{

    private String id;
    private String head;
    private String nickName;
    private String account;
    private String name;
    private String say;
    private String time;

    public Message(){

    }
    public Message( String id,String head, String nickName,String account ,String name, String say, String time) {
        this.id = id;
        this.head = head;
        this.nickName = nickName;
        this.account = account;
        this.name = name;
        this.say = say;
        this.time = time;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getHead() {
        return head;
    }

    public void setHead(String head) {
        this.head = head;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getSay() {
        return say;
    }

    public void setSay(String say) {
        this.say = say;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "Message{" +
                "id='" + id + '\'' +
                ", head='" + head + '\'' +
                ", nickName='" + nickName + '\'' +
                ", account='" + account + '\'' +
                ", say='" + say + '\'' +
                ", time='" + time + '\'' +
                '}';
    }


    public String sendMsg(String flag,String type,String content,Context context){
        if(User.getInstance()==null){
            User.getUserInfo(context);
        }

        String strMsg =   "{\"message\":{\"content\":\""+say+"\",\"s_account\":\""+account+"\",\"s_nickname\":\""+nickName+"\",\"s_name\":\""+name+"\"," +
                "\"f_name\":\""+User.getInstance().getName()+"\",\"f_id\":\""+User.getInstance().getId()+"\",\"editTime\":\""+time+"\",\"s_id\":\""+id+"\",\"f_account\":\""+User.getInstance().getPhone()+"\"," +
                "\"type\":\""+type+"\",\"f_nickname\":\""+User.getInstance().getNickname()+"\","+"\""+"content\":\""+content+"\""+"},\"type\":\""+flag+"\""+"}";

        return strMsg;
    }

    @Override
    public Message clone(){
        Message message  = null;
        try{
            message = (Message)super.clone();
        }catch(CloneNotSupportedException e){
            e.printStackTrace();
        }
        return message;
    }
}
